﻿<%@ WebHandler Language="C#" Class="TaskForOaProcess" %>

using System;
using System.Web;
using System.Net;
using System.IO;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using Business.Common;

public class TaskForOaProcess : IHttpHandler,System.Web.SessionState.IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        Common.Encrypt enTemp = new Common.Encrypt();
        string strTempCode = DateTime.Now.ToString("yyyyMMdd");
        //string strUserid = enTemp.DESEncrypt(HttpContext.Current.Session["RealUserId"].ToString(), strTempCode);
        string strUserid = DesOperation.DESEnCode(HttpContext.Current.Session["RealUserId"].ToString(), strTempCode);
        string strTaskType = "";        
        //strTaskType = enTemp.DESEncrypt("", strTempCode);
        //获取页码和一页显示的记录数
        int pageNumber = Int32.Parse(context.Request["page"]);
        int pageSize = Int32.Parse(context.Request["rows"]);
        int startRow = (pageNumber - 1) * pageSize+1;
        int endRow = pageNumber * pageSize;

        string strUrl = "http://10.20.17.30/PengingTaskServlet?method=getOAtask&data={\"userId\":\"" + strUserid + "\",\"startrow\":\"" + startRow + "\",\"finalrow\":\"" + endRow + "\",\"taskType\":\"" + strTaskType + "\"}";
        //strUrl = "http://localhost/gxoa/MyWindow/test.ashx";
        try
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
            request.Method = "GET";
            request.ContentType = "text/xml";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream resStream = response.GetResponseStream();
            StreamReader readStream = new StreamReader(resStream);
            string strGetData = readStream.ReadToEnd();

            //strGetData = "{\"total\":9,\"rows\":[{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":1,\"TASKCREATETIME\":\"2016-11-11 09:00:59\",\"SERVICESID\":\"10513\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21968\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12914\",\"TASKNAME\":\"国务院审改办关于部分行政审批中介服务事项征求意见的函\",\"TASKID\":\"21968\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":2,\"TASKCREATETIME\":\"2016-11-11 09:00:17\",\"SERVICESID\":\"10525\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21967\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12911\",\"TASKNAME\":\"科技部办公厅 财政部办公厅 发展改革委办公厅关于征求对《科技评估工作规定（试行）》意见的函\",\"TASKID\":\"21967\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":3,\"TASKCREATETIME\":\"2016-11-10 15:50:12\",\"SERVICESID\":\"10623\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21953\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12882\",\"TASKNAME\":\"广东省国土资源厅办公室关于赴国家测绘地理信息局学习地图管理工作的函\",\"TASKID\":\"21953\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":4,\"TASKCREATETIME\":\"2016-11-10 15:49:15\",\"SERVICESID\":\"10628\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21952\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12879\",\"TASKNAME\":\"中共中央组织部 国务院国资委党委关于印发《贯彻落实全国国有企业党的建设工作会议精神重点任务》的通知\",\"TASKID\":\"21952\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":5,\"TASKCREATETIME\":\"2016-11-10 15:48:44\",\"SERVICESID\":\"10608\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21951\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12876\",\"TASKNAME\":\"民政部办公厅关于确认2017年全国性行业协会商会脱钩试点名单（第三批）的通知\",\"TASKID\":\"21951\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":6,\"TASKCREATETIME\":\"2016-11-10 15:47:50\",\"SERVICESID\":\"10604\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21950\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12873\",\"TASKNAME\":\"贵州省人民政府关于恳请建设应急测绘保障贵阳中心的函\",\"TASKID\":\"21950\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":7,\"TASKCREATETIME\":\"2016-11-10 15:45:47\",\"SERVICESID\":\"10624\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21947\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12866\",\"TASKNAME\":\"中共中央组织部办公厅关于开展《2014-2018年全国党员教育培训工作规划》实施情况中期检查评估工作的通知\",\"TASKID\":\"21947\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":8,\"TASKCREATETIME\":\"2016-11-10 15:42:59\",\"SERVICESID\":\"10626\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21946\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12863\",\"TASKNAME\":\"中共中央组织部办公厅关于加强中央组织部文件保密管理有关事项的通知\",\"TASKID\":\"21946\",\"CREATORNAME\":\"张文婷\"},{\"TASKSTATE\":\"0\",\"APPROVALID\":\"zhangwt\",\"APPROVALNAME\":\"张文婷\",\"ROWNO\":9,\"TASKCREATETIME\":\"2016-11-09 08:47:24\",\"SERVICESID\":\"10511\",\"TASKURL\":\"http://10.20.17.20/EformAction.do?actionType=open&nid=21616\",\"DETAILURL\":\"http://10.20.17.20/workflow/ActLogAction.do?actionType=query\",\"MSID\":\"OA\",\"TASKTYPE\":\"收文\",\"ID\":\"12378\",\"TASKNAME\":\"关于协助办理变更《地理信息世界》主办单位的函\",\"TASKID\":\"21616\",\"CREATORNAME\":\"张文婷\"}]}";
            //List<Business.Struct.OaDaiBan> siTemp = Common.JsonOperation.GetObjectFromJson<List<Business.Struct.OaDaiBan>>(strGetData);
            //Business.Struct.OaDaiBan siTemp = Common.JsonOperation.GetObjectFromJson<Business.Struct.OaDaiBan>(strGetData);
            //string strReturn = "";
            //if (!string.IsNullOrEmpty(siTemp.data))
            //{
            //    strReturn = "{" + siTemp.othervalue.Replace("TOTALNUM", "total").Replace("}",",");
            //    strReturn += siTemp.data+"}";
            //}

            Common.Log.LogManage.addLogErr("测试", strGetData);
            context.Response.Write(strGetData);
        }
        catch (Exception ex)
        {
            Common.Log.LogManage.addLogErr(strUrl, ex.Message);
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}